package actions;

import javax.ejb.EJB;

import beans.BookManager;
import beans.BookManagerBean;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import entities.Item;

public class SaveItemAdminAction extends ActionSupport {
	
	@EJB
	private BookManager bookMgr = new BookManagerBean();
	private Item item = new Item();
	
	public String execute() {
		if (ActionContext.getContext().getSession().get("userId") == null) {
			return "loginerror";
		}
		if (bookMgr.updateMasterRecord(item)) {
			return "success";
		} else {
			return "error";
		}
	}

	public Item getItem() {
		return item;
	}

	public void setItem(Item item) {
		this.item = item;
	}
}
